package nz.ac.massey.doi_information_extractor.database;

import java.sql.SQLException;
import java.util.ArrayList;

import nz.ac.massey.doi_information_extractor.data.Author;
import nz.ac.massey.doi_information_extractor.data.Publication;

public interface DatabaseInterface {


	/**
	 * Reads a publication from the database using the DOI as a key
	 * @param doi the DOI to find the publication for
	 *
	 * @return The publication that relates to the DOI
	 * @throws SQLException
	 */
	Publication read(String doi) throws SQLException;

	/**
	 * Writes a publication to the database, if a entry exists update it
	 * else add a new publication to the disk
	 *
	 * @param publication The publication to write to the database
	 * @throws SQLException
	 */
	void write(Publication publication) throws SQLException;


	/**
	 * Deletes an item from the database
	 * @param doi
	 * @throws SQLException
	 */
	void delete(String doi) throws SQLException;


	/**
	 * Gets a list of all the DOIs in the database
	 * @throws SQLException
	 */
	String[] getDoiList() throws SQLException;

	/**
	 * Gets a list of all the authors in the database
	 * @return ArrayList of all authors in the database
	 * @throws SQLException
	 */
	ArrayList<Author> getAuthors() throws SQLException;

	/**
	 * Adds an author to the database, or if an author already exists updates that author
	 * @param author Author to add to the database
	 * @throws SQLException
	 */
	void writeAuthor(Author author) throws SQLException;

	/**
	 * Closes the connection to the database
	 */
	void closeConnection();
}

